import React, {Component} from 'react'
import {inject, observer} from 'mobx-react';
import {observable,action,toJS} from 'mobx';
import {Tabs, Modal,Table, Button, message} from 'antd'
const TabPane = Tabs.TabPane
const confirm = Modal.confirm;

import { WeaRichText, WeaDialog, WeaNewScroll,WeaAvatar,WeaInputSearch,WeaPopoverHrm } from 'ecCom'

//import WeaCkEditor from "../../Component/wea-ckeditor/CKEAppend"
import WeaWhitePage from "../../Component/wea-white-page"

import WeiboBar from "../RightContainer/Weibo/WeiboBar"

import ComVar from "../RightContainer/ComVar"
const {PublicRangeType, ComeFrom} = ComVar

import {WeaTools, WeaTop, WeaLeftRightLayout} from 'ecCom'
import Utils from './Utils'
const {RangeStar, BasicInfoCard, ToolTipBar, CustomerList, MessageItem} = Utils

import WeaCircleImage from "../../Component/wea-circle-image"

import WeaUtils from "../../Component/wea-utils"
const {DateFormat} = WeaUtils

import Mood from "../RightContainer/Weibo/Mood"
import _trim from 'lodash/trim';

import * as Util from '../../../util/index'
import Dict from '../../Component/wea-blog-dict';

const mirror = Dict.bottomBarMirror;

import { WeaLocaleProvider } from "ecCom";
import CubeLayout from "../../../../govern/components/E9/cubeLayout";
import EcmeBlogDialog from "../RightContainer/Weibo/EcmeBlogDialog";
import ViewMyBlog from "./ViewMyBlog";
const getLabel = WeaLocaleProvider.getLabel;
@inject('blogMyBlog')
@observer
class LeftContiner extends Component {

    constructor(props) {
        super(props)
        this.state = {
            showWorkRecord: false,
            showOperation: false,

            modalMessageVisible: false,
            modalTagVisible: false,
            authType: PublicRangeType.public,
            authRange: [],
            nowpage:2,
            mood: '1',
        }
        this.CKE_ID = "wea_ckeditor_weibo_tag"
        this.CKE_ID_RICH = "wea_ckeditor_weibo_richtext";

    }


    changeMood = (val) => {
        this.setState({mood:val});
    }

    componentDidMount() {
        let url = window.location.href;
        if(url.indexOf("/remindMessage")>0){
            this.setState({modalMessageVisible:true})
        }
        const {getIndexInfo,getBasicInfo,getReceiverList,getVisitorList,bqvisibleDialog} = this.props.blogMyBlog
        getIndexInfo()
        getBasicInfo()
        getReceiverList({
            recordType: "visit",
            currentPage: 1,
            pageSize: 5
        })
        getVisitorList({
            recordType: "access",
            currentPage: 1,
            pageSize: 5
        })

        if(window.location.href.indexOf("/homepage")>0){
            this.setState({modalTagVisible:bqvisibleDialog,nowpage:1})
        }else {
            this.setState({modalTagVisible:bqvisibleDialog})
        }

    }




    onSearchUser = (val) => {

        const {onSeachShareUserList} = this.props.blogMyBlog;
        onSeachShareUserList(val);
    }

    render() {
        let {authType, authRange} = this.state,
            {cardType, onClick, indexInfo={}, basicInfo: {countData = {}}, userInfo = {}, receiverList, visitorList, messageList, note, weiboCKEditorConfig} = this.props,
            {getReceiverList, getVisitorList,shareUserListVisible,getWeiboGroup,getFilterIds,cubeLayoutParame,getMessageList,ecmedialogspinning,richTextVisibleDialog} = this.props.blogMyBlog,
            {currentUser = {}} = userInfo,
            basicInfoCard = [
                {
                    id: 3,
                    name: getLabel(131542, "我的粉丝"),
                    value: countData.attentionMeTotalCount,
                    color: '#cc31ff',
                    onClick: () => {
                        onClick(3)
                    },
                    isActive: cardType == 3,
                    border: ["bottom"]
                },
                {
                    id: 4,
                    name: getLabel(26469, "我的关注"),
                    value: countData.myAttentionCount,
                    color: '#53c97a',
                    onClick: () => {
                        onClick(4);
                        getFilterIds()
                    },
                    isActive: cardType == 4,
                    border: ["bottom"]
                },
                {
                    id: 5,
                    name: getLabel(513653, "分享给我"),
                    value: countData.shareToMeUserCount,
                    color: '#447eff',
                    onClick: () => {
                        onClick(5)
                    },
                    isActive: cardType == 5,
                    border: ["bottom"]
                }
            ],
            toolTipBar = [
                {
                    name: getLabel(27128, "微博主页"),
                    tips: countData.updateCount,
                    icon: 'icon-coms-LargeArea',
                    color: '#447eff',
                    isActive:  cardType ==1,
                    type:'blogPage',
                    onClick: () => {
                        getWeiboGroup();
                        this.setState({nowpage:1});
                        onClick(1)
                    }

                },
                {
                    name: getLabel(26468, "我的微博"),
                    tips: countData.blogCount,
                    icon: 'icon-portal-blog-o',
                    isActive:  cardType ==2,
                    color: '#ff7725',
                    type:'isMyBlog',
                    onClick: () => {
                        this.setState({nowpage:2});
                        onClick(2)
                    }
                },

                {
                    name: getLabel(19085, "消息提醒"),
                    color: '#32a8ff',
                    icon: 'icon-blog-MessageReminder',
                    tips: countData.remindCount,
                    type:'blogmessage',
                    isActive: this.state.modalMessageVisible,
                    onClick: () => {
                        getMessageList();
                        this.setState({nowpage:3});
                        this.setModalMessageVisible(true)

                    }
                }
            ],
            messages = (messageList.remindList || []).map(
                item => {
                    const {id, username, msg, remindType, relatedid} = item,
                        params = {
                            id: id,
                            name: username,
                            type: remindType,
                            tips: msg,
                            relatedId: relatedid,
                            url: '',
                            onIgnoreClick: this.setMessageIgnore
                        }
                    if (remindType == 1) params.onAttentionClick = this.setAttentionStatus
                    return params
                }
            ),
            rangeStar = []

        if(indexInfo.work)
            rangeStar.push({
                name: getLabel(26929, "工作指数"),
                tip: indexInfo.work ? indexInfo.work.workIndexTitle : null,
                value: indexInfo.work ? indexInfo.work.workIndex : 0.0
            })
        if(indexInfo.mood)
            rangeStar.push({
                name: getLabel(26930, "心情指数"),
                tip: indexInfo.mood ? indexInfo.mood.moodIndexTitle : null,
                value: indexInfo.mood ? indexInfo.mood.moodIndex : 0.0
            })
        if(indexInfo.schedule)
            rangeStar.push({
                name: getLabel(26931, "考勤指数"),
                tip: indexInfo.schedule ? indexInfo.schedule.scheduleTitle : null,
                value: indexInfo.schedule ? indexInfo.schedule.scheduleIndex : 0.0
            })

        //暂时接入过来 zxt
        let bottomBarConfig = [];

        weiboCKEditorConfig && weiboCKEditorConfig.appList && weiboCKEditorConfig.appList.map((cg,key) => {
            cg.name === 'selects' && bottomBarConfig.push({
                name: 'Component',
                show: <Mood ecId={`${this && this.props && this.props.ecId || ''}_Mood@9lbe0t@${key}`} onSelect={mood => this.setState({mood})}/>
            })
            cg.name === 'dialogs' && cg.items.map(item => {
                let obj = {
                    isBlog: true,
                    name: 'Browser',
                    show: <div className="wea-cb-item">
                        <span className={`wea-cbi-icon ${mirror[item].icon}`}/>
                        <span className="wea-cbi-text">{mirror[item].nameFunc()}</span>
                    </div>,
                    type: mirror[item].type,
                    title: mirror[item].nameFunc(),
                    isSingle: item === 'Templet',
                };
                if(item === 'Templet'){
                    if(richTextVisibleDialog){
                        obj.onToolsChange = this.onDialogTempletChange
                    }else{
                        obj.onToolsChange = this.onTempletChange
                    }
                }


                bottomBarConfig.push(obj);
            })
            cg.name === 'uploads' && cg.items.map(item => {
                bottomBarConfig.push({
                    isBlog: true,
                    name: 'Upload',
                    show: <div className="wea-cb-item">
                        <span className='wea-cbi-icon icon-blog-Enclosure'/>
                        <span className="wea-cbi-text">{getLabel(156,"附件")}</span>
                    </div>,
                    uploadId: 'webo_edit',
                    uploadUrl: `${item.Attachment.uploadUrl}?category=${item.Attachment.position}`,
                    category: item.Attachment.position,
                    maxUploadSize: item.Attachment.maxSize,
                    style: {display: "inline-block"}
                })
            })
        })
        //暂时接入过来 zxt
        const {disabled,bqvisibleDialog,ecmevisibleDialog,getCardStorefun,changeEcmeVisDiaLog,richTextContent} =this.props.blogMyBlog;
        const style = {
            width: 70,
            height: 70,
            display: "inline-block"
        };
        let cubeFlag  = Object.keys(toJS(cubeLayoutParame)).length > 0;


       const columns = [
            {
                title: getLabel(25034,'姓名') ,
                dataIndex: 'name',
                key: 'name',
                render: (text, record, index) => {
                let hhref = "javaScript:openhrm("+record.key+");";
                  return  (
                      <div>
                          <WeaPopoverHrm ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@2xqi98@${index}`} />
                          <a
                              href={hhref}
                              onClick={e => window.pointerXY(e)}
                              title={text}
                          >
                              {text}
                          </a>
                      </div>
                  )
                },
                width: 100,
            },
            {
                title:  getLabel('27511',"部门"),
                dataIndex: 'deptTitle',
                key: 'deptTitle',
                width: 200,
            },
            {
                title: getLabel('33553',"分部"),
                dataIndex: 'subTitle',
                key: 'subTitle',
                width: 200,
            },
           {
               title: getLabel(6086,'岗位') ,
               dataIndex: 'jobTitle',
               key: 'jobTitle',
               width: 200,
           }]


        const moreBtn = { datas: []}
        return (
            <div className="wea-left-container">
                <div className="wea-lc-item wea-lc-top">
                    <div className="wea-lct-image">
                        <span style={style}>
                        <WeaAvatar ecId={`${this && this.props && this.props.ecId || ''}_WeaAvatar@emqwct`} userId={currentUser.id}/>
                        </span>
                    </div>
                    <div className="wea-lct-desc">
                        {
                            rangeStar.map((item,index) => {
                                return <RangeStar ecId={`${this && this.props && this.props.ecId || ''}_RangeStar@z60eqf@${index}`} {...item}/>
                            })
                        }
                    </div>
                </div>
                <div className="wea-lc-item wea-lc-middle">
                    {
                        basicInfoCard.map((item, key) => {
                            return <BasicInfoCard ecId={`${this && this.props && this.props.ecId || ''}_BasicInfoCard@nxq4z8@${key}`} {...item}  isCardWeiBo={1} className={key % 2 == 0 ? 'wea-lcc-even' : 'wea-lcc-odd'}/>
                        })
                    }
                </div>
                <div className="wea-lc-item wea-lc-bottom">
                    {
                        toolTipBar.map(item => {
                            return <ToolTipBar ecId={`${this && this.props && this.props.ecId || ''}_ToolTipBar@t50hqv@${item.type}`} {...item}/>
                        })
                    }
                </div>
                <Tabs ecId={`${this && this.props && this.props.ecId || ''}_Tabs@vzz7f9`} defaultActiveKey="1" size="small" className={'wea-basic-customer'} animated={false}>
                    <TabPane ecId={`${this && this.props && this.props.ecId || ''}_TabPane@2apiad`} tab={getLabel(26934, "最近来访")} key="1">
                        <CustomerList ecId={`${this && this.props && this.props.ecId || ''}_CustomerList@xhk90l`} type="visit" records={receiverList} getList={getReceiverList}/>
                    </TabPane>
                    <TabPane ecId={`${this && this.props && this.props.ecId || ''}_TabPane@ssh4xt`} tab={getLabel(26935, "最近访问")} key="2">
                        <CustomerList ecId={`${this && this.props && this.props.ecId || ''}_CustomerList@x5bkbs`} type="access" records={visitorList} getList={getVisitorList}/>
                    </TabPane>
                </Tabs>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@r4esq4`}
                    title={getLabel(19085, "消息提醒")}
                    icon="icon-coms-blog"
                    iconBgcolor="#6d3cf7"
                    buttons={[
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@466lyzsetMessageIgnore`}
                            key="ignore" type="primary"
                            disabled={!!!messages.length}
                            onClick={()=> this.setMessageIgnore('all')}
                        >{getLabel(384387, "全部忽略")}</Button>,
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vueoe3setModalMessageVisible`}
                            key="back" type="ghost"
                            onClick={() => this.setModalMessageVisible(false)}
                        >{getLabel(31129, "取消")}</Button>
                    ]}
                    style={{width: 720, height: 520}}
                    visible={this.state.modalMessageVisible}
                    onCancel={() => this.setModalMessageVisible(false)}
                >
                    <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@13y3ua`} style={{ height: 520}}>
                        {
                            messages && messages.length > 0 ? (
                                messages.map((item,index) => {
                                    return <MessageItem ecId={`${this && this.props && this.props.ecId || ''}_MessageItem@n6oc9j@${index}`} {...item}/>
                                })
                            ) : <div style={{"margin-top": "29%"}}><WeaWhitePage ecId={`${this && this.props && this.props.ecId || ''}_WeaWhitePage@rtda3m`} style={{ height: 520}} type="message"/></div>
                        }
                    </WeaNewScroll>
                </WeaDialog>

                <EcmeBlogDialog ecId={`${this && this.props && this.props.ecId || ''}_EcmeBlogDialog@gpp9yj`}
                    ecmedialogspinning={ecmedialogspinning}
                    cancelEcmeTag={this.cancelEcmeTag}
                    publishBlogEcme={this.publishBlogEcme}
                    cubeLayoutParame={cubeLayoutParame}
                    changeMood={this.changeMood}
                    ecmevisibleDialog={ecmevisibleDialog}
                    getCardStorefun={getCardStorefun}
                    changeEcmeVisDiaLog={changeEcmeVisDiaLog}
                    disabled={disabled}
                />

                <ViewMyBlog ecId={`${this && this.props && this.props.ecId || ''}_ViewMyBlog@m9amwq`}/>


                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@vuhq43`}
                    title={getLabel(33304, "微博便签")}
                    icon="icon-coms-blog"
                    iconBgcolor="#6d3cf7"
                    buttons={[
                        <WeiboBar ecId={`${this && this.props && this.props.ecId || ''}_WeiboBar@t82zjk@weibobarblognote`}
                            authType={authType}
                            authRange={authRange}
                            onAuthType={this.onAuthType}
                            onAuthRange={this.onAuthRange}
                            cancelClick={this.cancelTag}
                            publishClick={this.publishWeiboPermission}
                            saveClick={this.saveTag}
                            disabled={disabled}
                            style={{
                                border: "none",
                                padding: 0,
                                height: 28,
                                lineHeight: 28
                            }}
                        />
                    ]}
                    style={{width:720, height: 489}}
                    visible={bqvisibleDialog}
                    onCancel={this.cancelTag}
                >
                    <div className='wea-ckeditor-import-ecCom wea-blog-bianqian'>
                        <WeaRichText ecId={`${this && this.props && this.props.ecId || ''}_WeaRichText@9wew6n`}
                            id={this.CKE_ID}
                            ref={this.CKE_ID}
                            value={note.content || ""}
                            ckConfig={{
                                toolbar:[
                                    { name: 'document', items: [ 'Source'] },
                                    { name: 'paragraph', items: [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', '-', 'NumberedList', 'BulletedList' ] },
                                    { name: 'styles', items: [ 'Format', 'Font', 'FontSize' ] },
                                    { name: 'colors', items: [ 'TextColor' ] },
                                    { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline', 'Strike'] },
                                    { name: 'insert', items: [ 'Image', 'Table', 'Smiley'] },
                                    { name: 'tools', items: [ 'Maximize' ] }
                                ],
                                extraPlugins: 'markdown',
                                height:369,
                                uploadUrl: '/api/blog/fileupload/uploadimage',
                                resize_enabled: false,
                            }}
                            bottomBarConfig={ bottomBarConfig }
                            onToolsChange={Util.transfStr}
                        />
                    </div>
                </WeaDialog>

                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@ud870y`}
                    title="微博编辑"
                    icon="icon-coms-blog"
                    iconBgcolor="#6d3cf7"
                    buttons={[
                        <WeiboBar ecId={`${this && this.props && this.props.ecId || ''}_WeiboBar@vvuxpxweibobarbianji`}
                            authType={authType}
                            authRange={authRange}
                            onAuthType={this.onAuthType}
                            onAuthRange={this.onAuthRange}
                            cancelClick={this.cancelRichTag}
                            saveClick={this.saveRichTag}
                            disabled={disabled}
                            style={{
                                border: "none",
                                padding: 0,
                                height: 28,
                                lineHeight: 28
                            }}
                        />
                    ]}
                    style={{width:720, height: 462}}
                    visible={richTextVisibleDialog}
                    onCancel={this.cancelRichTag}
                >
                    <div className='wea-ckeditor-import-ecCom wea-blog-bianqian'>
                        <WeaRichText ecId={`${this && this.props && this.props.ecId || ''}_WeaRichText@jg5t5a`}
                            id={this.CKE_ID_RICH}
                            ref={this.CKE_ID_RICH}
                            value={richTextContent || ""}
                            ckConfig={{
                                toolbar:[
                                    { name: 'document', items: [ 'Source'] },
                                    { name: 'paragraph', items: [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', '-', 'NumberedList', 'BulletedList' ] },
                                    { name: 'styles', items: [ 'Format', 'Font', 'FontSize' ] },
                                    { name: 'colors', items: [ 'TextColor' ] },
                                    { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline', 'Strike'] },
                                    { name: 'insert', items: [ 'Image', 'Table', 'Smiley'] },
                                    { name: 'tools', items: [ 'Maximize' ] }
                                ],
                                extraPlugins: 'markdown',
                                height:369,
                                uploadUrl: '/api/blog/fileupload/uploadimage',
                                resize_enabled: false,
                            }}
                            bottomBarConfig={ bottomBarConfig }
                            onToolsChange={Util.transfStr}
                        />
                    </div>
                </WeaDialog>

                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@ud870ydissshare`}
                           title={this.props.blogMyBlog.showUserTitle}
                           icon="icon-coms-blog"
                           iconBgcolor="#6d3cf7"
                           style={{width:720, height: 462}}
                           visible={shareUserListVisible}
                           onCancel={this.cancelDisscussShare}
                           moreBtn={moreBtn}
                >
                    <WeaInputSearch ecId={`${this && this.props && this.props.ecId || ''}_WeaInputSearch@xga7v9`}
                        style={{"margin-left": 525,"height": 35,"padding": 2}}
                        onSearch={this.onSearchUser}
                    />
                    <Table ecId={`${this && this.props && this.props.ecId || ''}_Table@ma6jyl`} columns={columns} scroll={{ y: 386 }}  size="small" pagination={false} dataSource={this.props.blogMyBlog.discussShareUserList} />

                </WeaDialog>
            </div>
        )
    }


    onDialogTempletChange = (name, ids, list, type) => {





        const {getEcmeTemlate,ecmeid,changeRichOrEcme,changeEcmedilogspin,changeEcmeVisible,changeRichTextDia} = this.props.blogMyBlog;
        Modal.confirm({
            title: getLabel(505615,'替换当前内容？'),
            onOk: () => {
                if(list[0]&&list[0].contentType==1){
                    changeEcmedilogspin(true);
                    changeRichTextDia(false);
                    changeEcmeVisible(true);
                    getEcmeTemlate({templateId:list[0].id},result => {
                        changeRichOrEcme(1,result.data,result.partid)
                    })
                }else{
                    changeRichTextDia(true);
                    changeEcmeVisible(false);
                    changeRichOrEcme(0,list[0].name);
                }
            },
            onCancel: () => {

            }
        });




    }


    onTempletChange = (name, ids, list, type) => {
        if(this.refs[this.CKE_ID].wrappedInstance){
            Util.templetChange(this.refs[this.CKE_ID].wrappedInstance.getData(),v =>this.refs[this.CKE_ID].wrappedInstance.setData(v), name, ids, list, type)
        }else{
            Util.templetChange(this.refs[this.CKE_ID].getData(),v =>this.refs[this.CKE_ID].setData(v), name, ids, list, type)
        }
    }

    setModalMessageVisible = (modalMessageVisible) => {
        this.setState({modalMessageVisible: modalMessageVisible})
    }

    setMessageIgnore = (id, type) => {
        const {ignoreMessage, getBasicInfo,ignoreMessages } = this.props.blogMyBlog
        if (id!='all') {
            ignoreMessage(
                {id: id, remindType: type},
                () => {
                    getBasicInfo()
                }
            )
        } else {
            ignoreMessages(
                () => {
                    getBasicInfo()
                }
            )
        }
    }
    setAttentionStatus = (id, relatedId, status) => {
        const {approveMessage,getBasicInfo} = this.props.blogMyBlog;
        approveMessage(
            {id: id, relatedId: relatedId, opt: status},
            () => {
                getBasicInfo()
            }
        )
    }

    setModalTagVisible = (modalTagVisible) => {
        let {getNote} = this.props.blogMyBlog;
        getNote();
        this.setState({modalTagVisible: modalTagVisible})
    }

    saveRichTag = () => {
        let contents = '';

        if(this.refs[this.CKE_ID_RICH].wrappedInstance){
            contents = this.refs[this.CKE_ID_RICH].wrappedInstance.getData();
        }else{
            contents = this.refs[this.CKE_ID_RICH].getData();
        }

        let {changeRichTextVisDiaLog,updateBlogEcmeinfo,ecmeid,setDisabled} = this.props.blogMyBlog,
            {authType, authRange} = this.state
        let ckref = '';

        if(this.refs[this.CKE_ID_RICH].wrappedInstance){
            ckref = this.refs[this.CKE_ID_RICH].wrappedInstance;
        }else{
            ckref = this.refs[this.CKE_ID_RICH];
        }

        if (!ckref.checkMode()) {
            message.error(getLabel('384536',"不能以源码模式或markdown模式保存，请将编辑器切换到可视化模式"));
            return;
        }

        updateBlogEcmeinfo({ blogId:ecmeid,partid:0,content:contents}, result => {
            if(result.status){
                changeRichTextVisDiaLog(false)
                setTimeout(() => {
                    setDisabled(false)
                }, 1000)
            }

        })


    }

    saveTag = () => {
        let contents = '';

        if(this.refs[this.CKE_ID].wrappedInstance){
            contents = this.refs[this.CKE_ID].wrappedInstance.getData();
        }else{
            contents = this.refs[this.CKE_ID].getData();
        }

        let {saveNote,getNote,changeBqVisDiaLog} = this.props.blogMyBlog,
            {authType, authRange} = this.state
        let ckref = '';

        if(this.refs[this.CKE_ID].wrappedInstance){
            ckref = this.refs[this.CKE_ID].wrappedInstance;
        }else{
            ckref = this.refs[this.CKE_ID];
        }

        if (!ckref.checkMode()) {
            message.error(getLabel('384536',"不能以源码模式或markdown模式保存，请将编辑器切换到可视化模式"));
            return;
        }
        saveNote(
            {content: contents},
            result => {
                if (result.status == "1") {
                    getNote()
                }
            }
        )

        changeBqVisDiaLog(false)
        this.setModalTagVisible(false)
    }





    publishBlogEcme = (callback = false) => {
        let {Card,setDisabled,saveBlogEcmeInfo,ecmefbworkdate,cubeLayoutParame,ecmeid,updateBlogEcmeinfo,changeEcmedilogspin,changeEcmeVisDiaLog,partid} = this.props.blogMyBlog;
        let ecmeExtend = {};
        if (Object.keys(cubeLayoutParame).length > 0) {//建模布局保存方法
            const { ecmeDoSubmit } = Card.Actions;
            ecmeDoSubmit().then((data) => {
                ecmeExtend= data.JSONStr.extendDatas;
                let {mood} = this.state,
                    workdate = ecmefbworkdate;
                if(ecmefbworkdate==null||ecmefbworkdate==""||ecmefbworkdate==undefined){
                    workdate = DateFormat(new Date(), "yyyy-MM-dd");
                }
                typeof setDisabled === 'function' && setDisabled(true);
                let params = {
                ecmeExtend: JSON.stringify(ecmeExtend),
                    appItemId: mood || "1",
                    comefrom: ComeFrom.pc,
                    content: "none",
                    workdate: workdate,
                    blogId:ecmeid,
                    partid:partid

            }
           if(params.blogId==undefined){
               saveBlogEcmeInfo(
                   params,
                   result => {
                       if (result.status) {
                           changeEcmeVisDiaLog(false);
                           changeEcmedilogspin(true);
                           setTimeout(() => {
                               setDisabled(false)
                           }, 1000)
                       }
                   }
               )
           }else{
               updateBlogEcmeinfo(
                   params,
                   result => {
                       if (result.status) {
                           changeEcmeVisDiaLog(false);
                           changeEcmedilogspin(true);
                           setTimeout(() => {
                               setDisabled(false)
                           }, 1000)
                       }
                   }
               )
           }

            })
        }
    }

    publishWeiboPermission = () => {
        let {getIsOneSubmitInfo,setIsNoTip} = this.props.blogMyBlog;
        let {authType, authRange, mood, richValue} = this.state,
          {blogType, user, workdate} = this.props
        let _this = this;
        getIsOneSubmitInfo(result => {
          if (result.oneSubmit == "1" && result.submitCount>0) {
              message.warning(getLabel('521404',"您已发布过今天的微博，不能再发布，已为您保存草稿。"));
              setIsNoTip(true);
              this.saveTag();
          }else{
            if(result.oneSubmit == "1"&& result.submitCount==0){
              confirm({//
                title: getLabel('131329',"信息确认"),
                content: getLabel('521430',"当日微博仅能提交一次，确定要发布吗？"),
                onOk() {
                  _this.publishTag();
                },
                onCancel() {},
              });
            }else{
              _this.publishTag();
            }
          }
        })
      }


    publishTag = () => {
        let { cardType} = this.props,
            {editWeibo, getBasicInfo,setDisabled, getNote,changeBqVisDiaLog,changeEdit,bqfbworkdate} = this.props.blogMyBlog,
            {authType, authRange, mood} = this.state,
            workdate = bqfbworkdate;
        changeEdit( {bqshowEdit: false, bqediting: false});
        if(bqfbworkdate==null||bqfbworkdate==""||bqfbworkdate==undefined){
            workdate = DateFormat(new Date(), "yyyy-MM-dd");
        }
        let ckref = '';
        typeof setDisabled === 'function' && setDisabled(true);
        if(this.refs[this.CKE_ID].wrappedInstance){
            ckref = this.refs[this.CKE_ID].wrappedInstance;
        }else{
            ckref = this.refs[this.CKE_ID];
        }
        if (!ckref.checkMode()) {
            message.error(getLabel('384536',"不能以源码模式或markdown模式保存，请将编辑器切换到可视化模式"));
            return;
        }
        let content = _trim(ckref.getData()) || '';
        if (!content) {
            message.error(getLabel('383036','请输入内容') );
            typeof setDisabled === 'function' && setDisabled(false);
            return;
        }
        let params = {
            appItemId: mood || "1",
            comefrom: ComeFrom.pc,
            content: content,
            workdate: workdate,
            fromTag:"1"
        }

        editWeibo(params, {workdate: workdate},
            result => {
                if (result.status == "1") {
                    getBasicInfo()
                    getNote()
                    changeBqVisDiaLog(false)
                }
                message.destroy();
                message.success(getLabel('83885',"操作成功！"));
            }
        )
    }

    cancelEcmeTag = () => {
        const {changeEcmeVisDiaLog,changeEcmedilogspin} = this.props.blogMyBlog;
        changeEcmeVisDiaLog(false)
        changeEcmedilogspin(true);
    }

    cancelTag = () => {
        const {changeBqVisDiaLog} = this.props.blogMyBlog;
        changeBqVisDiaLog(false)
    }


    cancelRichTag = () => {
        const {changeRichTextVisDiaLog} = this.props.blogMyBlog;
        changeRichTextVisDiaLog(false)
    }
    cancelDisscussShare = () => {
        const {changeShareUserListVisible} = this.props.blogMyBlog;
        changeShareUserListVisible(false);
    }

    onAuthType = (authType) => {
        this.setState({authType: authType})
    }

    onAuthRange = (authRange) => {
        this.setState({authRange: authRange})
    }
}

export default LeftContiner



